#include "BreakPointFile.h"

#include "FileStreamBinaryPersist.h"

BreakPointFile::BreakPointFile(const std::string & filePath)
: imp(new FileStreamBinaryPersist(filePath))
{
} 

BreakPointFile::~BreakPointFile(){
    if(imp){
        delete imp;
        imp = nullptr;
    }
}

const long long BreakPointFile::get() const {
    imp->open();
    const long long seqNo = imp->readLongLong();
    imp->close();
    return seqNo; 
}
void BreakPointFile::set(const long long seqNo){
   imp->open();
   imp->writeLongLong(seqNo);
   imp->flush();
   imp->close();
}
void BreakPointFile::add(const long long step) {
    set(get() + step);
}
